<?php
namespace app\admin\model;
use think\Model;
use think\Db;


class Book extends Model
{
	public function getDataAll($status){
		$start = input('get.start');
		$end = input('get.end');
		$book_name = input('get.book_name');
		
		//只显示状态为传过来的值的数据
		$where ="status = $status";

		//开始时间 
		if ($start) {
			$start = strtotime($start);
			$where .= " and UNIX_TIMESTAMP(add_time) >= $start";
		}
		//结束时间
		if ($end) {
			$end = strtotime($end)+60*60*24;
			$where .= " and UNIX_TIMESTAMP(add_time) <= $end";
		}

		if ($book_name) {
			$where .= " and book_name = '$book_name'";
		}


		

		
		

		// echo $where;
		//当前$this指Admin模型
		$data = Db::name('book_info')->where($where)->paginate(5,false,['query'=>array('start'=>$start,'end'=>$end,'book_name'=>$book_name)]);
		// dump($data);
		return $data;
	} 


	public function addBook($data){

		// $info = Db::name('book_info')->where('id_card',$data['id_card'])->find();

		// if($info){
		// 	return false;
		// }


		$data = Db::name('book_info')->insert($data);

		return $data;
	}
	

	public function editStudents($id){
		
		$data = Db::name('students')->where('id',$id)->find();
		// dump($data);die;
		
		
		return $data;
	}
}